package com.test.languagetest;

import org.hibernate.SessionFactory;
import org.hibernate.cfg.Configuration;
import org.hibernate.classic.Session;

import com.pojo.Product;

public class HibernateTestUpdateOneById {

	
	public static void main(String[] args) {
		
		SessionFactory sf = new Configuration().configure().buildSessionFactory();
		Session s = sf.openSession();
		s.beginTransaction();
		
		Product p = (Product) s.get(Product.class, 5);
		if(null != p)
		System.out.println(p.getName());
		
		p.setName("phone-modified");
		
		s.update(p);
		
		s.getTransaction().commit();
		s.close();
		sf.close();
	}
}
